package gatperdut.chato.constants;

import gatperdut.chato.model.Chato.Constant.Fluid;
import gatperdut.chato.model.Chato.Constant.impl.ConstantPackageImpl;

import org.eclipse.emf.ecore.EEnumLiteral;

public final class CSConstantsFood {

    public static String getFluidName( Fluid f ) {
        switch ( f ) {
        case BEER:
            return "beer";
        case OIL:
            return "oil";
        case WATER:
            return "water";
        case WINE:
            return "wine";
        default:
            throw new IllegalArgumentException( "Obtaining name for an unknown fluid." );
        }
    }

    public static int getFluidDensity( Fluid f ) {
        EEnumLiteral enumLiteral = ConstantPackageImpl.eINSTANCE.getFluid().getEEnumLiteralByLiteral( f.getLiteral() );
        String weightPerUnit = enumLiteral.getEAnnotation( "properties" ).getDetails().get( "density" );
        return Integer.parseInt( weightPerUnit );
    }

    private final static String EAT_100 = "all of";

    private final static String EAT_75 = "most of";

    private final static String EAT_50 = "a lot of";

    private final static String EAT_25 = "some bites of";

    private final static String EAT_0 = "a little of";

    public static String getEatingPortionDescription( float amount, float maxAmount ) {
        float factor = amount / maxAmount;

        if ( factor == 1.0 ) {
            return EAT_100;
        }
        if ( factor >= 0.75 ) {
            return EAT_75;
        }
        if ( factor >= 0.5 ) {
            return EAT_50;
        }
        if ( factor >= 0.25 ) {
            return EAT_25;
        }

        return EAT_0;
    }

    private final static String DRINK_100 = "all";

    private final static String DRINK_75 = "most";

    private final static String DRINK_50 = "a lot";

    private final static String DRINK_25 = "some gulps";

    private final static String DRINK_0 = "a few sips";

    public static String getDrinkingPortionDescription( float amount, float maxAmount ) {
        float factor = amount / maxAmount;

        if ( factor == 1.0 ) {
            return DRINK_100;
        }
        if ( factor >= 0.75 ) {
            return DRINK_75;
        }
        if ( factor >= 0.5 ) {
            return DRINK_50;
        }
        if ( factor >= 0.25 ) {
            return DRINK_25;
        }

        return DRINK_0;
    }

    private final static String DRINKABLE_LEFTOVER_100 = "filled with";

    private final static String DRINKABLE_LEFTOVER_75 = "almost full with";

    private final static String DRINKABLE_LEFTOVER_50 = "with some";

    private final static String DRINKABLE_LEFTOVER_25 = "with a little";

    private final static String DRINKABLE_LEFTOVER_0 = "with very little";

    public static String getDrinkableLeftovers( float amount, float maxAmount ) {
        float factor = amount / maxAmount;

        if ( factor == 1.0 ) {
            return DRINKABLE_LEFTOVER_100;
        }
        if ( factor >= 0.75 ) {
            return DRINKABLE_LEFTOVER_75;
        }
        if ( factor >= 0.5 ) {
            return DRINKABLE_LEFTOVER_50;
        }
        if ( factor >= 0.25 ) {
            return DRINKABLE_LEFTOVER_25;
        }

        return DRINKABLE_LEFTOVER_0;
    }

    private final static String EDIBLE_LEFTOVER_100 = "all of";

    private final static String EDIBLE_LEFTOVER_75 = "most of";

    private final static String EDIBLE_LEFTOVER_50 = "more than half of";

    private final static String EDIBLE_LEFTOVER_25 = "some part of";

    private final static String EDIBLE_LEFTOVER_0 = "scraps of";

    public static String getEdibleLeftovers( float amount, float maxAmount ) {
        float factor = amount / maxAmount;

        if ( factor == 1.0 ) {
            return EDIBLE_LEFTOVER_100;
        }
        if ( factor >= 0.75 ) {
            return EDIBLE_LEFTOVER_75;
        }
        if ( factor >= 0.5 ) {
            return EDIBLE_LEFTOVER_50;
        }
        if ( factor >= 0.25 ) {
            return EDIBLE_LEFTOVER_25;
        }

        return EDIBLE_LEFTOVER_0;
    }

    private final static String EDIBLE_LEFTOVER_LABEL_100 = "whole";

    private final static String EDIBLE_LEFTOVER_LABEL_75 = "partly eaten";

    private final static String EDIBLE_LEFTOVER_LABEL_50 = "half-eaten";

    private final static String EDIBLE_LEFTOVER_LABEL_25 = "mostly eaten";

    private final static String EDIBLE_LEFTOVER_LABEL_0 = "scraps";

    public static String getEdibleLeftoversLabel( float amount, float maxAmount ) {
        float factor = amount / maxAmount;

        if ( factor == 1.0 ) {
            return EDIBLE_LEFTOVER_LABEL_100;
        }
        if ( factor >= 0.75 ) {
            return EDIBLE_LEFTOVER_LABEL_75;
        }
        if ( factor >= 0.5 ) {
            return EDIBLE_LEFTOVER_LABEL_50;
        }
        if ( factor >= 0.25 ) {
            return EDIBLE_LEFTOVER_LABEL_25;
        }

        return EDIBLE_LEFTOVER_LABEL_0;
    }

}
